"""
演示RDD的filter成员方法的使用
"""
from pyspark import SparkContext, SparkConf
import os

os.environ['PYSPARK_PYTHON'] = "D:/Work/anaconda3/python.exe"

conf = SparkConf().setMaster("local[*]").setAppName("test_spark")
sc = SparkContext(conf=conf)

# 准备一个RDD
rdd = sc.parallelize([i for i in range(1, 11)])

# 对RDD的数据进行过滤，返回True则保留该数据，False则过滤掉该数据
even_number_rdd = rdd.filter(lambda x: x % 2 == 0)

print(even_number_rdd.collect())